/**
 * 转换工具相关
 */
#pragma once

#include <app/util/attribute-storage.h>

namespace tools {

// 工具函数
// utility for extracting attribute data in HandleReadAttribute implementations
template <typename T>
static chip::Protocols::InteractionModel::Status GetAttr(uint8_t* aBuffer, uint16_t aMaxReadLength, T aValue) {
    using ST = typename chip::app::NumericAttributeTraits<T>::StorageType;
    if (aMaxReadLength == sizeof(ST)) {
        *reinterpret_cast<ST*>(aBuffer) = aValue;
        return chip::Protocols::InteractionModel::Status::Success;
    }
    return chip::Protocols::InteractionModel::Status::UnsupportedRead;
}

}
